package edu.pitt.dbmi.odie.gapp.gwt.server.util.oba;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;

public class ODIE_ObaTestCaller {

//	public static final String PROD_URL = "http://rest.bioontology.org/obs_hibernate/annotator?email=";
	public static final String PROD_URL = "http://rest.bioontology.org/obs/annotator?email=";
	
	private static String text = "Melanoma is a malignant tumor of melanocytes which are found predominantly in skin but also in the bowel and the eye";

	public static void main(String[] args) {
		System.out
				.println("********************* NCBO ANNOTATOR CLIENT TEST ************************* \n");
		try {
			String emailAddress = args[0] ;
			String urlPath = PROD_URL + emailAddress + "&#34" ;
			HttpClient client = new HttpClient();
			PostMethod method = new PostMethod(urlPath);

			// Configure the form parameters
			
//			longestOnly=false
//			wholeWordOnly=true
//			stopWords=true
//			scored=true
//			ontologiesToExpand=13578
//			ontologiesToKeepInResult=13578
//			levelMin=0
//			levelMax=0
//			mappingTypes=null
//			format=asXML
			
			method.addParameter("longestOnly", "false");
			method.addParameter("wholeWordOnly", "true");
//		    method.addParameter("stopWords", "true");
//		    method.addParameter("withDefaultStopWords", "true");
			method.addParameter("scored", "true");
		    method.addParameter("ontologiesToExpand", "13578");
			// "38802,13578,NCI,SNOMEDCT");
			method.addParameter("ontologiesToKeepInResult", "13578");
//			method.addParameter("levelMin", "0");
//			method.addParameter("levelMax", "0");
			// method.addParameter("semanticTypes", "T999");
			// method.addParameter("levelMax", "50");
			method.addParameter("mappingTypes", "null");
			method.addParameter("textToAnnotate", text);
			// method.addParameter("format", "asText");

			// Execute the POST method
			int statusCode = client.executeMethod(method);
			if (statusCode != -1) {
				String contents = method.getResponseBodyAsString();
				method.releaseConnection();
				System.out.println(contents);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
